//
//  XuanZe.swift
//  Swift-LeetCode
//
//  Created by 卢悦明 on 2024/3/1.
//

import UIKit

class XuanZe: NSObject {

    static func xuanZe(_ array: [Int]) -> [Int] {
        var array = array
        for end in (1...array.count-1).reversed() {
            var maxIndx = 0
            for begin in 1...end {
                if array[begin] >= array[maxIndx] {
                    maxIndx = begin
                }
            }
            (array[maxIndx], array[end]) = (array[end], array[maxIndx])
        }
        return array
    }
}
